package com.itheima.project.config;

import feign.Logger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.search.SearchModule;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;

/**
 * @ClassName SearchFeignConfig.java
 * @Description feign的最优化配置
 */
@EnableFeignClients(basePackages = "com.itheima.project.feign"
        ,defaultConfiguration = SearchFeignConfig.class)
@Configuration
public class SearchFeignConfig {
    @Bean
    public Logger.Level level(){
        // 设置feign 的日志
        return Logger.Level.FULL;
    }
    @Bean
    public NamedXContentRegistry namedXContentRegistry(){
        SearchModule searchModule =
                new SearchModule(Settings.EMPTY, false, Collections.emptyList());
        return new NamedXContentRegistry(searchModule.getNamedXContents());
    }


}
